﻿using ConfExpert.Utility;
using DevTeam;

using System;
using System.Data;

namespace ConfExpert.Forms.Depo.Aksesuar
{
    public partial class _AksJoker : XPopupForm
    {
        int ProductCategoryId, A;
        public _AksJoker(int ProductCategoryId, int A)
        {
            InitializeComponent();
            this.ProductCategoryId = ProductCategoryId;
            this.A = A;
            this.Text = AppSession.Lookups.ProductCategory.FindByProductCategoryId(ProductCategoryId)["Name"].ToString() + "- " +
                AppSession.Lookups.ProductCategory.FindByProductCategoryId(ProductCategoryId)["A" + A.ToString()].ToString();
        }

        private void AksJoker_Load(object sender, EventArgs e)
        {


            gridView1.Init("GetAksJoker", ProductCategoryId, A);
            gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            gridView1.DataTable().TableNewRow += AksJoker_TableNewRow;
            gridView1.MakeColumnInvisible("AksJokerId", "ProductCategoryId", "A");

            barButtonItem1.ItemClick += barButtonItem1_ItemClick;
            gridView1.AddSummary();
            gridView1.BestFitColumns();
        }

        void AksJoker_TableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            e.Row["ProductCategoryId"] = ProductCategoryId;
            e.Row["A"] = A;
        }

        void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.EndEditing();
            gridView1.Update("", "AksJoker");
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
